<?php $url = new Url(); ?>
<div class="left">
    <?php $this->widget("AdminKetquaTrongngay")?>
    <?php $this->widget("AdminKetquaXoso")?>
</div>
<div class="right-main">
    <div class="righ-cont">
        <div class="right">
            <div class="title_style">
                <span><b>Kết quả xổ số Miền Trung </b></span>
            </div>
            <p>Mở thưởng <?=StringUtils::getDayViText($day["wday"])?>, <?=date("d/m/Y",time()) ?></p>
            <div class="tablestyle clearfix">
                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                    <tbody>   
                        <tr>
                            <td>
                                <div class="table clearfix">
                                    <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                        <tbody>   

                                            <tr class="bg_gray">
                                                <td width="23%" class="text-left">&nbsp;</td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td width="25%"><strong class="clblue"><?=$rowProvince[$i]["name"] ?></strong> </td>
                                                    <input type="hidden" id="province_id<?=$i?>" value="<?=$rowProvince[$i]["id"] ?>"/>
                                                    <?php }?>
                                                <td width="9%">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải tám : </strong> <span id="giai8"></span></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?> 
                                                    <td>
                                                        <b class="clblue"><input id="giai_tam<?=$i?>" value="<?=isset($rows[$i]["giai_tam"])? $rows[$i]["giai_tam"]:"" ?>" style="width: 50px;" /></b>
                                                    </td>                                               
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiaitam();" class="save"> Save</a></td>

                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải bảy : </strong> <span id="giai7"></span></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?> 
                                                    <td>
                                                        <b class="clblue"><input id="giai_bay<?=$i?>" value="<?=isset($rows[$i]["giai_bay"])? $rows[$i]["giai_bay"]:"" ?>" style="width: 50px;" /></b>

                                                    </td>                                               
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiaibay();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải sáu:</strong> <span id="giai6"></span></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td>
                                                        <p><b class="clblue"><input id="giai_sau_1<?=$i?>" value="<?=isset($rows[$i]["giai_sau_1"])? $rows[$i]["giai_sau_1"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_sau_2<?=$i?>" value="<?=isset($rows[$i]["giai_sau_2"])? $rows[$i]["giai_sau_2"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_sau_3<?=$i?>" value="<?=isset($rows[$i]["giai_sau_3"])? $rows[$i]["giai_sau_3"]:"" ?>" style="width: 50px;" /></b></p>
                                                    </td>
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiaisau();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải năm: </strong> <span id="giai5"></span></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?> 
                                                    <td>
                                                        <b class="clblue"><input id="giai_nam<?=$i?>" value="<?=isset($rows[$i]["giai_nam"])? $rows[$i]["giai_nam"]:"" ?>" style="width: 50px;" /></b>
                                                    </td>                                               
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiainam();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><p><strong>Giải tư: </strong><span id="giai4"></span></p></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td>
                                                        <p><b class="clblue"><input id="giai_tu_1<?=$i?>" value="<?=isset($rows[$i]["giai_tu_1"])? $rows[$i]["giai_tu_1"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_tu_2<?=$i?>" value="<?=isset($rows[$i]["giai_tu_2"])? $rows[$i]["giai_tu_2"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_tu_3<?=$i?>" value="<?=isset($rows[$i]["giai_tu_3"])? $rows[$i]["giai_tu_3"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_tu_4<?=$i?>" value="<?=isset($rows[$i]["giai_tu_4"])? $rows[$i]["giai_tu_4"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_tu_5<?=$i?>" value="<?=isset($rows[$i]["giai_tu_5"])? $rows[$i]["giai_tu_5"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_tu_6<?=$i?>" value="<?=isset($rows[$i]["giai_tu_6"])? $rows[$i]["giai_tu_6"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_tu_7<?=$i?>" value="<?=isset($rows[$i]["giai_tu_7"])? $rows[$i]["giai_tu_7"]:"" ?>" style="width: 50px;" /></b></p>
                                                    </td>
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiaitu();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><p><strong>Giải ba: </strong><span id="giai3"></span></p></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td>
                                                        <p><b class="clblue"><input id="giai_ba_1<?=$i?>" value="<?=isset($rows[$i]["giai_ba_1"])? $rows[$i]["giai_ba_1"]:"" ?>" style="width: 50px;" /></b></p>
                                                        <p><b class="clblue"><input id="giai_ba_2<?=$i?>" value="<?=isset($rows[$i]["giai_ba_2"])? $rows[$i]["giai_ba_2"]:"" ?>" style="width: 50px;" /></b></p>

                                                    </td>
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiaiba();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải nhì: </strong><span id="giai2"></span></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td>
                                                        <p><b class="clblue"><input id="giai_nhi<?=$i?>" value="<?=isset($rows[$i]["giai_nhi"])? $rows[$i]["giai_nhi"]:"" ?>" style="width: 50px;" /></b></p>

                                                    </td>
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiainhi();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải nhất: </strong></strong><span id="giai1"></span></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td>
                                                        <p><b class="clblue"><input id="giai_nhat<?=$i?>" value="<?=isset($rows[$i]["giai_nhat"])? $rows[$i]["giai_nhat"]:"" ?>" style="width: 50px;" /></b></p>

                                                    </td>
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiainhat();" class="save"> Save</a></td>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải đặc biệt: </strong><span id="giaidb"></span></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td>
                                                        <p><b class="clblue"><input id="giai_dacbiet<?=$i?>" value="<?=isset($rows[$i]["giai_dacbiet"])? $rows[$i]["giai_dacbiet"]:"" ?>" style="width: 50px;" /></b></p>

                                                    </td>
                                                    <?php }?>
                                                <td width="9%" class="bg_yellow"><a href="javascript:void(0)" onclick="saveGiaidacbiet();" class="save"> Save</a></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                            <td width="60"><a href="#" class="next"></a></td>
                            <td>
                                <div class="table clearfix">
                                    <table cellspacing="0" cellpadding="0" border="0" width="100%">
                                        <tbody>   

                                            <tr class="bg_gray">
                                                <td width="20%" class="text-left">&nbsp;</td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td width="27%"><strong class="clblue"><?=$rowProvince[$i]["name"] ?></strong></td> 
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải tám</strong></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td><b class="clblue" id="g8<?=$i?>"><?=isset($rows[$i]["giai_tam"]) ?$rows[$i]["giai_tam"]:"" ?></b></td>
                                                    <?php }?>                                            
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải bảy</strong></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td><b class="clblue" id="g7<?=$i?>"><?=isset($rows[$i]["giai_bay"]) ?$rows[$i]["giai_bay"]:"" ?></b></td>
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải sáu</strong></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td >
                                                        <p><b class="clblue" id="g61<?=$i?>"><?=isset($rows[$i]["giai_sau_1"]) ?$rows[$i]["giai_sau_1"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g62<?=$i?>"><?=isset($rows[$i]["giai_sau_2"]) ?$rows[$i]["giai_sau_2"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g63<?=$i?>"><?=isset($rows[$i]["giai_sau_3"]) ?$rows[$i]["giai_sau_3"]:"" ?></b></p>
                                                    </td>
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải năm</strong></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td><b class="clblue" id="g5<?=$i?>"><?=isset($rows[$i]["giai_nam"]) ?$rows[$i]["giai_nam"]:"" ?></b></td>
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><p><strong>Giải tư</strong></p></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td >
                                                        <p><b class="clblue" id="g41<?=$i?>"><?=isset($rows[$i]["giai_tu_1"]) ?$rows[$i]["giai_tu_1"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g42<?=$i?>"><?=isset($rows[$i]["giai_tu_2"]) ?$rows[$i]["giai_tu_2"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g43<?=$i?>"><?=isset($rows[$i]["giai_tu_3"]) ?$rows[$i]["giai_tu_3"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g44<?=$i?>"><?=isset($rows[$i]["giai_tu_4"]) ?$rows[$i]["giai_tu_4"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g45<?=$i?>"><?=isset($rows[$i]["giai_tu_5"]) ?$rows[$i]["giai_tu_5"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g46<?=$i?>"><?=isset($rows[$i]["giai_tu_6"]) ?$rows[$i]["giai_tu_6"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g47<?=$i?>"><?=isset($rows[$i]["giai_tu_7"]) ?$rows[$i]["giai_tu_7"]:"" ?></b></p>
                                                    </td>
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><p><strong>Giải ba</strong></p></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td >
                                                        <p><b class="clblue" id="g31<?=$i?>"><?=isset($rows[$i]["giai_ba_1"]) ?$rows[$i]["giai_ba_1"]:"" ?></b></p>
                                                        <p><b class="clblue" id="g32<?=$i?>"><?=isset($rows[$i]["giai_ba_2"]) ?$rows[$i]["giai_ba_2"]:"" ?></b></p>
                                                    </td>
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải nhì</strong></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td><b class="clblue" id="g2<?=$i?>"><?=isset($rows[$i]["giai_nhi"]) ?$rows[$i]["giai_nhi"]:"" ?></b></td>
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải nhất</strong></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td><b class="clblue" id="g1<?=$i?>"><?=isset($rows[$i]["giai_nhat"]) ?$rows[$i]["giai_nhat"]:"" ?></b></td>
                                                    <?php }?>
                                            </tr>
                                            <tr>
                                                <td class="text-left"><strong>Giải đặc biệt</strong></td>
                                                <?php for($i=0;$i<count($rowProvince);$i++){?>
                                                    <td><b class="clblue" id="gdb<?=$i?>"><?=isset($rows[$i]["giai_dacbiet"]) ?$rows[$i]["giai_dacbiet"]:"" ?></b></td>
                                                    <?php }?>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var ngay_quay = '<?=date("Y-m-d",time()) ?>';
    var count_province = <?=count($rowProvince); ?>;
    function saveGiaidacbiet(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiDacbietMientrung") ?>';
        var giai_dacbiet = ""; 
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_dacbiet += $("#giai_dacbiet"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_dacbiet:giai_dacbiet,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giaidb").removeClass("loading");
                if(msg==1){                   
                    $("#giaidb").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#gdb"+i).html($("#giai_dacbiet"+i).val());
                    }
                }else{
                    $("#giaidb").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giaidb").html("");
                $("#giaidb").addClass("loading");
            }
        });    
    }
    function saveGiainhat(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiNhatMientrung") ?>';
        var giai_nhat = ""; 
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_nhat += $("#giai_nhat"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_nhat:giai_nhat,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai1").removeClass("loading");
                if(msg==1){                   
                    $("#giai1").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g1"+i).html($("#giai_nhat"+i).val());
                    }
                }else{
                    $("#giai1").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai1").html("");
                $("#giai1").addClass("loading");
            }
        });    
    }
    function saveGiainhi(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiNhiMientrung") ?>';
        var giai_nhi = ""; 
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_nhi += $("#giai_nhi"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_nhi:giai_nhi,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai2").removeClass("loading");
                if(msg==1){                   
                    $("#giai2").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g2"+i).html($("#giai_nhi"+i).val());
                    }
                }else{
                    $("#giai2").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai2").html("");
                $("#giai2").addClass("loading");
            }
        });    
    }
    function saveGiaiba(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiBaMientrung") ?>';
        var giai_ba_1 = "";
        var giai_ba_2 = "";  
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_ba_1 += $("#giai_ba_1"+i).val()+";";
            giai_ba_2 += $("#giai_ba_2"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_ba_1:giai_ba_1,
                giai_ba_2:giai_ba_2,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai3").removeClass("loading");
                if(msg==1){                   
                    $("#giai3").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g31"+i).html($("#giai_ba_1"+i).val());
                        $("#g32"+i).html($("#giai_ba_2"+i).val());
                    }
                }else{
                    $("#giai3").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai3").html("");
                $("#giai3").addClass("loading");
            }
        });    
    }
    function saveGiaitu(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiTuMientrung") ?>';
        var giai_tu_1 = "";
        var giai_tu_2 = ""; 
        var giai_tu_3 = "";
        var giai_tu_4 = "";
        var giai_tu_5 = ""; 
        var giai_tu_6 = "";
        var giai_tu_7 = ""; 
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_tu_1 += $("#giai_tu_1"+i).val()+";";
            giai_tu_2 += $("#giai_tu_2"+i).val()+";";
            giai_tu_3 += $("#giai_tu_3"+i).val()+";";
            giai_tu_4 += $("#giai_tu_4"+i).val()+";";
            giai_tu_5 += $("#giai_tu_5"+i).val()+";";
            giai_tu_6 += $("#giai_tu_6"+i).val()+";";
            giai_tu_7 += $("#giai_tu_7"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }    
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_tu_1:giai_tu_1,
                giai_tu_2:giai_tu_2,
                giai_tu_3:giai_tu_3,
                giai_tu_4:giai_tu_4,
                giai_tu_5:giai_tu_5,
                giai_tu_6:giai_tu_6,
                giai_tu_7:giai_tu_7,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){

                $("#giai4").removeClass("loading");
                if(msg==1){                   
                    $("#giai4").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g41"+i).html($("#giai_tu_1"+i).val());
                        $("#g42"+i).html($("#giai_tu_2"+i).val());
                        $("#g43"+i).html($("#giai_tu_3"+i).val());
                        $("#g44"+i).html($("#giai_tu_4"+i).val());
                        $("#g45"+i).html($("#giai_tu_5"+i).val());
                        $("#g46"+i).html($("#giai_tu_6"+i).val());
                        $("#g47"+i).html($("#giai_tu_7"+i).val());
                    }
                }else{
                    $("#giai4").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai4").html("");
                $("#giai4").addClass("loading");
            }
        });    
    }
    function saveGiainam(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiNamMientrung") ?>';
        var giai_nam = "";
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_nam += $("#giai_nam"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_nam:giai_nam,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                //alert(msg);
                $("#giai5").removeClass("loading");
                if(msg==1){                   
                    $("#giai5").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g5"+i).html($("#giai_nam"+i).val());
                    }
                }else{
                    $("#giai5").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai5").html("");
                $("#giai5").addClass("loading");
            }
        });    
    }
    function saveGiaisau(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiSauMientrung") ?>';
        var giai_sau_1 = "";
        var giai_sau_2 = ""; 
        var giai_sau_3 = ""; 
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_sau_1 += $("#giai_sau_1"+i).val()+";";
            giai_sau_2 += $("#giai_sau_2"+i).val()+";";
            giai_sau_3 += $("#giai_sau_3"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_sau_1:giai_sau_1,
                giai_sau_2:giai_sau_2,
                giai_sau_3:giai_sau_3,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai6").removeClass("loading");
                if(msg==1){                   
                    $("#giai6").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g61"+i).html($("#giai_sau_1"+i).val());
                        $("#g62"+i).html($("#giai_sau_2"+i).val());
                        $("#g63"+i).html($("#giai_sau_3"+i).val());
                    }
                }else{
                    $("#giai6").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai6").html("");
                $("#giai6").addClass("loading");
            }
        });    
    }
    function saveGiaibay(){  
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiBayMientrung") ?>';
        var giai_bay = "";
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_bay += $("#giai_bay"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_bay:giai_bay,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){
                $("#giai7").removeClass("loading");
                if(msg==1){                   
                    $("#giai7").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g7"+i).html($("#giai_bay"+i).val());
                    }
                }else{
                    $("#giai7").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai7").html("");
                $("#giai7").addClass("loading");
            }
        });    

    }

    function saveGiaitam(){
        var strUrl = '<?=$url->createUrl("trongngay/saveGiaiTamMientrung") ?>';
        var giai_tam = "";
        var province_id = "";
        for(var i=0;i<count_province;i++){
            giai_tam += $("#giai_tam"+i).val()+";";
            province_id +=$("#province_id"+i).val()+";";
        }

        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                giai_tam:giai_tam,
                province_id:province_id,
                ngay_quay:ngay_quay
            },
            success: function(msg){  
                //alert(msg);
                $("#giai8").removeClass("loading");
                if(msg==1){                   
                    $("#giai8").html("OK");
                    for(var i=0;i<count_province;i++){
                        $("#g8"+i).html($("#giai_tam"+i).val());
                    }
                }else{
                    $("#giai8").html("Loi");
                }       
            },
            beforeSend:function(){
                $("#giai8").html("");
                $("#giai8").addClass("loading");
            }
        });    

    }
</script>